package org.nightrunner.d3.service.impl;

import java.io.Serializable;
import java.util.List;

import org.nightrunner.d3.dao.IEquipmentDao;
import org.nightrunner.d3.entity.Equipment;
import org.nightrunner.d3.model.DefaultPaginationInfo;
import org.nightrunner.d3.model.IPaginationInfo;
import org.nightrunner.d3.model.PaginationModel;
import org.nightrunner.d3.service.IEquipmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Equipment Service implementation
 * 
 * @author NigthRunner
 * @date 2012-7-26
 * @version 1.0
 */

@Service
public class EquipmentService implements IEquipmentService {

	@Autowired
	private IEquipmentDao equipmentDao;

	public IEquipmentDao getEquipmentDao() {
		return equipmentDao;
	}

	public void setEquipmentDao(IEquipmentDao equipmentDao) {
		this.equipmentDao = equipmentDao;
	}

	public Serializable addEquipment(Equipment equipment) {
		return equipmentDao.save(equipment);
	}

	public Equipment getEquipment(String bureauId) {
		return equipmentDao.get(bureauId);
	}

	public List<Equipment> getAllEquipment() {
		return equipmentDao.list();
	}

	public void deleteEquipment(Equipment equipment) {
		equipmentDao.delete(equipment);
	}

	public PaginationModel<List<Equipment>> getEquipment() {
		IPaginationInfo paginationInfo = new DefaultPaginationInfo();
		paginationInfo.setCurrentPage(0);
		paginationInfo.setRowSize(10);
		return getEquipments(paginationInfo);
	}

	public PaginationModel<List<Equipment>> getEquipments(
			IPaginationInfo pagination) {
		return equipmentDao.find(pagination);
	}

	public void updateEquipment(Equipment equipment) {
		equipmentDao.merge(equipment);
	}
}
